import { IGlobalApi } from './IGlobalApi'
import { RequestManager } from './request/RequestManager'

import { ESApp } from '@extscreen/es3-vue'
import { GlobalApiKey } from './UseApi'


export function createGlobalApi(): IGlobalApi {
  let requestManager: RequestManager
  function init(...params: any[]): Promise<any> {
    requestManager = params[0]
    return Promise.resolve()
  }

  return {
    install: function (app: ESApp) {
      const instance = this
      app.provide(GlobalApiKey, instance)
    },
    init,
  }
}
